import parole
from parole.colornames import colors
from parole.display import interpolateRGB
import pygame, random

import sim, sim_items, main, interface
from util import *

class ScrollIdentify(sim_items.Scroll):
    def __init__(self):
        sim_items.Scroll.__init__(self, "naming", "?", 
                ('see', 'have'),
                idDescription="The reader of this scroll will find that he "\
                    "instantly and miraculously understands the true name "\
                    "and function of one chosen item that he carries.")

    def read(self, reader):
        assert(reader is main.player)

        def __handleChooseId(target):
            if target.unidTemplate and not reader.recognizes(target):
                reader.identify(target, 
                    msgTemplate='Suddenly you feel certain that %s is in fact '
                                '%s.')
                reader.identify(self)
            else:
                main.transient('Nothing seems to happend.')

        def __cancelChooseId():
            main.transient("%s is wasted." % self.noun(definite=1,
                capitalized=1))

        interface.ObjectChooser(reader.inventory, __handleChooseId,
                __cancelChooseId,
                title="{\Gold Choose an item.}").push()


#========================================
thingClass = ScrollIdentify
